package com.sz.common.pay.common;

import java.text.DecimalFormat;
import java.util.UUID;

/**
 * Function: 用于银行请示响应时的序列记录<br>
 *     使用长度为四位的数字，000000－999999，到达最大时进行重新。显示保持四位风格。
 * Author: siqishangshu <br>
 * Date: 2017-10-26 16:11:00
 */
public class SequenceGenerator {

    private static int SEQUENCE_NUMBER = 0;
    private static int SEQUENCE_MAX = 100000;

    public synchronized static String getSequenceNumber(){
        SEQUENCE_NUMBER = (++SEQUENCE_NUMBER) % SEQUENCE_MAX;
        DecimalFormat df = new DecimalFormat("000000");
        return df.format(SEQUENCE_NUMBER);
    }

    /**
     * len must be 20
     * @return third log no
     */
    public synchronized static String getThirdLogNo(){
        return DateGenerator.getyyyyMMddHHmmss()+getSequenceNumber();
    }

    public static Object getUUID() {
            return UUID.randomUUID().toString().replaceAll("-", "");
    }
}
